package educationaladministrationsystem.CSM.Mapper.Service.StudentAndTeacher.Student;

import educationaladministrationsystem.CSM.Mapper.Service.ServiceInterface.StudentAndTeacherInterface.Student.StudentCourseSelection;
import educationaladministrationsystem.Class.Course;
import educationaladministrationsystem.CSM.Mapper.StudentAndTeacher.Student.StudentCourseSelectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentCourseSelectionService implements StudentCourseSelection {
    @Autowired
    private StudentCourseSelectionMapper studentCourseSelectionMapper;

    @Override
    public List<Course> getAllCourse(String id, int page, int pageNumber) {
        return studentCourseSelectionMapper.getAllCourse(id, (page - 1) * pageNumber, pageNumber);
    }

    @Override
    public int getPageSum(String id, int pageNumber) {
        return (int) Math.ceil((double) studentCourseSelectionMapper.getCourseCount(id) / pageNumber);
    }
}
